Posts

Post marked as solved
2 Replies
3.1k Views
I've got a UIBarButtonItem in my app that currently presents an action sheet of items. I want to switch this to a UIMenu with iOS 14's new APIs for buttons and bar button items. But somme of the contents of the action sheet change based on the state of the view controller when the action sheet is triggered. With the action sheet, I generate a different action sheet every time the bar button item's target action is called. But with the new APIs, I have to generate the menu ahead of time and assign it to the button. What's the best way to get the menu to update every time it's presented? I tried UIDeferredMenuElement, but it caches the result of its provider. Feedback FB7824467 suggests adding a property to UIDeferredMenuElement to disable the caching of the provider result.
Posted Last updated
.
Post not yet marked as solved
0 Replies
723 Views
I have an iOS app that can play audio books as FairPlay DRM'd audio streams. I'm using AVContentKeySession to fetch keys and AVQueuePlayer to play. It works great on iOS, but on Catalyst (Monterey 12.3.1, M1 Max MacBook Pro) it crashes. When it happens in debug, I get a message "Too few bits left in input buffer" printed to the console, and an exception is thrown in the guts of what appears to be core media. Here's the output from [NSThread callStackSymbols] when paused on an exception breakpoint at that point: 0   ???                       0x0000000156b8cc9c 0x0 + 5749918876, 1   BRFree                    0x000000010445cf08 main + 0, 2   AudioCodecs               0x0000000157918c24 _ZL11GetPropertyPvjPjS_ + 52, 3   AudioToolboxCore          0x00000001862536a4 _ZN15ADTSAudioStream11ParseHeaderER27AudioFileStreamContinuation + 1060, 4   AudioToolboxCore          0x000000018624259c AudioFileStreamParseBytes + 412, 5   MediaToolbox              0x00000001915f7d98 FigManifoldCreateForICY + 2176, 6   MediaToolbox              0x00000001915f7718 FigManifoldCreateForICY + 512, 7   MediaToolbox              0x00000001916bbd78 FigPlayerStreamCreate + 315920, 8   MediaToolbox              0x0000000191a269a0 FigMetadataConverterCreateForQuickTimeToFromiTunes + 45888, 9   MediaToolbox              0x0000000191a4a290 FigMetadataConverterCreateForQuickTimeToFromiTunes + 191536, 10  MediaToolbox              0x0000000191a2a470 FigMetadataConverterCreateForQuickTimeToFromiTunes + 60944, 11  MediaToolbox              0x0000000191a28c34 FigMetadataConverterCreateForQuickTimeToFromiTunes + 54740, 12  MediaToolbox              0x0000000191a413b4 FigMetadataConverterCreateForQuickTimeToFromiTunes + 154964, 13  MediaToolbox              0x0000000191a2f144 FigMetadataConverterCreateForQuickTimeToFromiTunes + 80612, 14  MediaToolbox              0x00000001917cae64 FigAlternateFilterMonitorCreateForThermalNotification + 30428, 15  MediaToolbox              0x00000001917ccb44 FigAlternateFilterMonitorCreateForThermalNotification + 37820, 16  MediaToolbox              0x00000001917cb134 FigAlternateFilterMonitorCreateForThermalNotification + 31148, 17  CFNetwork                 0x0000000189937cd4 _CFHostIsDomainTopLevelForCertificatePolicy + 27728, 18  Foundation                0x0000000185ba980c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24, 19  Foundation                0x0000000185ba96b4 -[NSBlockOperation main] + 104, 20  Foundation                0x0000000185ba9644 __NSOPERATION_IS_INVOKING_MAIN__ + 24, 21  Foundation                0x0000000185ba88dc -[NSOperation start] + 788, 22  Foundation                0x0000000185ba85c0 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 24, 23  Foundation                0x0000000185ba8478 __NSOQSchedule_f + 184, 24  libdispatch.dylib         0x00000001099f60f4 _dispatch_block_async_invoke2 + 148, 25  libdispatch.dylib         0x00000001099e2394 _dispatch_client_callout + 20, 26  libdispatch.dylib         0x00000001099eb778 _dispatch_lane_serial_drain + 980, 27  libdispatch.dylib         0x00000001099ec814 _dispatch_lane_invoke + 492, 28  libdispatch.dylib         0x00000001099f9fc8 _dispatch_root_queue_drain + 408, 29  libdispatch.dylib         0x00000001099f9d3c _dispatch_worker_thread + 264, 30  libsystem_pthread.dylib   0x00000001094e1890 _pthread_start + 148, 31  libsystem_pthread.dylib   0x00000001094ebaa8 thread_start + 8 In the Debug Navigator, the top of the stack looks a little different: #0 0x0000000184bdeb3c in __cxa_throw () #1 0x000000015791941c in ACMP4AACLowComplexityDecoder::GetProperty(unsigned int, unsigned int&, void*) () #2 0x0000000157918c24 in GetProperty(void*, unsigned int, unsigned int*, void*) () #3 0x00000001862536a4 in ADTSAudioStream::ParseHeader(AudioFileStreamContinuation&) () #4 0x000000018624259c in AudioFileStreamParseBytes () #5 0x00000001915f7d98 in ___lldb_unnamed_symbol598$$MediaToolbox () What's going wrong here? Can anyone give me direction on what to fix? Or is FairPlay audio not even expected to work in Catalyst at this point?
Posted Last updated
.
Post not yet marked as solved
2 Replies
1k Views
I have an iPad app in which I'm starting to support multiple windows / scenes. I have one main window type, let's say MainScene, and at least one secondary window type for opening specific types of content, say DetailScene. I have not declared my scene types in Info.plist. I have implemented application:configurationForConnectingSceneSession:options: like this: -(UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { NSUserActivity *activity = options.userActivities.anyObject; NSString *activityType = activity.activityType; if ([activityType isEqualToString:@"detailType"]) return [DetailSceneDelegate makeSceneConfiguration]; return [MainSceneDelegate makeSceneConfiguration]; } Say I perform these steps: Launch app for the first time. I get a call to configurationForConnectingSceneSession, and the activity type is nil so it returns a MainScene. Open a new window for some piece of content. That uses the detail scene activity type, so configurationForConnectingSceneSession returns a DetailScene. Creating the new scene looks like this: NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"detailType"]; activity.userInfo = @{@"content_id": @(contentRowId)}; [[UIApplication sharedApplication] requestSceneSessionActivation:nil userActivity:activity options:nil errorHandler:nil]; Suspend the app and open the app switcher. Discard (by flicking up) first the main window and then the detail window. The app is now killed. Relaunch the app. At this point I do not get a call to configurationForConnectingSceneSession. I get the detail scene back, restored from its user activity, with calls straight to DetailSceneDelegate. My question: how do I control what scene gets restored in this situation? I want my main scene to come back. Messages and Mail and Notes all do this. If you open Messages and drag a conversation out into a new window, you get a window for that conversation with a Done button in the corner that will dismiss the window. If you perform my steps above with Messages, you will relaunch to the full Messages view. Are they converting the detail view to a main view on the fly? Or is there a way to tell the system that the detail scene is secondary and should not be restored first, or that I should get asked what I want to restore via configurationForConnectingSceneSession? Or something else?
Posted Last updated
.
Post not yet marked as solved
0 Replies
424 Views
As of iOS 14, UICollectionViewDiffableDataSource has a reorderHandlers property. It's demonstrated in some sample code and talked about in WWDC 2020 session on Advances in Diffable Data Sources. The presenter states that you have to provide a canReorder and didReorder closure to enable the feature. The sample code uses it in a collection view with a list layout configuration, and configures the list cells with reorder accessories. The canReorder and didReorder methods are called as expected. But if I remove the reorder accessories from the cells, reordering no longer works - it doesn't call either closure. It also doesn't work in my app, where I have a grid layout using a compositional layout. How do I enable reordering on UICollectionViewDiffableDataSource without list cells and reorder accessories?
Posted Last updated
.
Post not yet marked as solved
1 Replies
468 Views
I have a UICollectionView that I feed data into using UICollectionViewDiffableDataSource. I want to display a scroll scrubber on the trailing edge of it, like I'd get if I implemented the data source methods indexTitlesForCollectionView and indexPathForIndexTitle. But the data source is the diffable data source object, and there's no property or closure on it to supply index titles as of iOS 15. How are index titles supposed to work with UICollectionViewDiffableDataSource?
Posted Last updated
.
Post marked as solved
3 Replies
995 Views
I notice in iOS 14 beta 4, collection views show index views on their trailing edge if the data source implements indexTitlesForCollectionView - https://developer.apple.com/documentation/uikit/uicollectionviewdatasource/2851455-indextitlesforcollectionview?language=objc and indexPathForIndexTitle - https://developer.apple.com/documentation/uikit/uicollectionviewdatasource/2851456-collectionview?language=objc. But I don't see a way to control any aspect of its appearance. On UITableView this shows up as the sectionIndexColor - https://developer.apple.com/documentation/uikit/uitableview/1614915-sectionindexcolor?language=objc property. Does this property exist on UICollectionView somewhere I didn't think to look? Or is it just not there (yet)? FB8284500
Posted Last updated
.
Post marked as solved
2 Replies
2.4k Views
In the session on StoreKit 2 (which looks amazing!), the presenter says: In fact, if your app is running when a purchase is made on another device, you'll be notified about the new transaction. This seems to mean that when an app uses the listener API to be notified of transactions, it will get transactions that happened on other devices. My app offers purchases across other platforms in addition to iOS, and when a purchase happens we register it with our own account system. If a user has the app running on both their iPad and iPhone and makes a purchase on the phone, if the iPad gets notified of it the same way it would of a purchase made on the iPad, both devices will try to report it to our system. This seems undesirable. What's the recommended approach here? Should we just make sure our system will disregard duplicate transaction reports? Or is there a way to know whether a transaction originated on this device? I don't see a property on the transaction type that looks like it could accomplish this. Maybe the deviceVerification properties? But that's seems more like the new edition of transaction receipt verification - failing that check would presumably mean that the purchase is invalid, not that it didn't happen on this device...?
Posted Last updated
.
Post not yet marked as solved
0 Replies
570 Views
I work on an e-reader app that sells books as IAPs. We have a lot - about 20,000 or so. This is over Apple's limit of 10,000 IAPs, so we've had to ask them to raise the limit for us more than once. Recently, at Apple's suggestion, we finally switched to a mechanism called Price Tiers, where instead of having one IAP item in App Store Connect for each of our products, we have one item per price level, so if the user buys product ID (in our system) 12345 for $5, instead of buying non-consumable IAP ID com.mycompany.myapp.12345, they buy consumable IAP ID com.mycompany.myapp.price_tier.5. In our system, we link the purchase to product 12345 at the time of receipt verification and everything works great. But I have an issue that manifests when the user is using Ask to Buy or when receipt validation fails in our back-end, I don't call finishTransaction, and the transaction is retried later. The sequence is this: User buys product 12345, which is com.mycompany.myapp.price_tier.5 The user has Ask to Buy enabled, so the transaction ends in the deferred state, and the IAP flow on the device is done for now At some point later, the user gets permission for the purchase, and my SKPaymentQueue delegate gets notified of the transaction again in the background But at the point of step 3, I have no way of knowing what product in our system the transaction is for. The same issue occurs if receipt verification fails on our end - I don't call finishTransaction, so StoreKit retries it later, but again at that point I don't know which one of our products to register to the user's account. How do I make Ask to Buy (or any situation where I get notified of a transaction outside of a user-driven purchase) work with Price Tiers?
Posted Last updated
.
Post not yet marked as solved
1 Replies
714 Views
I have a UICollectionView tied to a UICollectionViewDiffableDataSource, and I'm generating and applying snapshots to the datasource on a background serial queue, and generating cells using UICollectionViewCellRegistration. I'm working on supporting reordering of the contents of the collection view via drag and drop, and I'm having trouble with what to do in collectionView:performDropWithCoordinator: so the reorder animation looks right. Normally, I would do something like this: -(void)collectionView:(UICollectionView *)collectionView performDropWithCoordinator:(id<UICollectionViewDropCoordinator>)coordinator { NSIndexPath *sourcePath = (NSIndexPath *)coordinator.items.firstObject.dragItem.localObject; NSInteger fromIndex = sourcePath.item; NSInteger toIndex = coordinator.destinationIndexPath.item; NSNumber *fromItem = [self.datasource itemIdentifierForIndexPath:sourcePath]; NSNumber *toItem = [self.datasource itemIdentifierForIndexPath:coordinator.destinationIndexPath]; //Do the move in the data model [MyModel moveItemFrom:fromIndex to:toIndex]; //Do the move in the datasource. This is the data source equivalent of: //[collectionView moveItemAtIndexPath:sourcePath toIndexPath:coordinator.destinationIndexPath]; NSDiffableDataSourceSnapshot *snap = self.datasource.snapshot; if (toIndex < fromIndex) [snap moveItemWithIdentifier:fromItem beforeItemWithIdentifier:toItem]; else [snap moveItemWithIdentifier:fromItem afterItemWithIdentifier:toItem]; [self.dataSource applySnapshot:snap animated:YES]; //Drop the item [coordinator dropItem:coordinator.items.firstObject.dragItem toItemAtIndexPath:coordinator.destinationIndexPath]; } But because my datasource updates happen on a background queue, I have to do at least the snapshot generation and application asynchronously, and I'd like to do the actual data model modification there too to avoid hangs. And I need to call dropItem on the coordinator on the main queue in this method. This results in an odd animation where the dropped item momentarily disappears (when drop is called) and then reappears (when the data source is updated on the background queue). The best idea I have so far is to use UICollectionViewDropPlaceholder to hold the place in the collection view until the data source is updated. But to create a placeholder I need a cell reuse identifier (docs on init method), and I don't have one of those because I'm creating my cells using cell registrations. So my question: what do I do in the performDrop method to make this work correctly? If the placeholder is the right idea, how do I use it in this situation?
Posted Last updated
.
Post marked as solved
2 Replies
984 Views
I'm working on enabling Catalyst for my existing iOS app. When I try to archive and export Catalyst as a Developer ID-signed Mac app, I get the following error: Cannot create a Mac Catalyst Developer ID provisioning profile for "[my bundle ID]". The Siri capability is not available for Mac Catalyst Developer ID provisioning profiles. Disable this feature and try again. My iOS app uses SiriKit to donate a Siri intent, so Siri is among the capabilities listed in the Signing and Capabilities tab in the project inspector in Xcode. I don't see a way to turn that capability off only for Catalyst (like you can link some frameworks only for Catalyst or iOS), and I don't want to disable Siri entirely in my iOS app. What's going on here? What do I need to do to "disable this feature" for Catalyst?
Posted Last updated
.
Post marked as solved
1 Replies
952 Views
I want to offer a pay-as-you-go introductory offer for a subscription in my iOS app. But it's not clear to me what the actual pricing is if the offer is on a subscription whose period is more than 1 unit (2 month, 3 month, 6 month, etc). For example, say I have a subscription that costs $20 per renewal and renews every 6 months. I set up an intro offer of the "Pay as you go" type (SKProductDiscountPaymentModePayAsYouGo) whose duration is 12 months and price is $10. Is the user going to get charged $10/month for 12 months (renewing 12 times), or $10 per 6 months for 12 months (renewing twice)? The documentation - https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/implementing_introductory_offers_in_your_app?language=objc isn't all that clear on this. If I set this up with a local StoreKit test file - https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode?language=objc and try it in a simulator, the system purchase sheet appears to actually display it wrong. In my scenario above, the simulator shows a trial of "$10 per month for 2 months". I've filed this as FB8998598.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.8k Views
In the session "Widgets Code Along Part 2" in WWDC 2020, the presenter says - https://developer.apple.com/videos/play/wwdc2020-10035/?time=174: Widgets do not have animation or custom interactions, but we can deep link from our widget into our app. SystemSmall widgets are one large tap area, while systemMedium and systemLarge can use the new SwiftUI link API to create tappable zones within the widget. This suggests that I should be able to designate regions of my widget as tappable that lead to a given URL in my app. But the Link - https://developer.apple.com/documentation/swiftui/link API just takes a string title and a destination URL - it doesn't appear to be able to embed other arbitrary views like images. How do I use the Link API to designate regions of my widget as tappable, instead of just text links?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
Cross-posted on Stack Overflow - https://stackoverflow.com/q/64105606/412107. If my Mac app hangs, it generates diagnostic files that end in .hang or .cpu_resource.diag. They look somewhat like crash reports, but with deep tab-indented hierarchies of what looks like process samples. Example: Powerstats for:&#9;MyApp [13095] thread 0x9b152 UUID:&#9;&#9;&#9;&#9;&#9;&#9;35BE255F-F3B3-3188-B1E4-12E96CAAD397 Start time:&#9;&#9;&#9;2020-09-26 15:37:35 -0500 End time:&#9;&#9;&#9;&#9;2020-09-26 15:39:03 -0500 Parent:&#9;&#9;&#9;&#9;&#9;launchd Microstackshots: 55 samples (47%) Primary state:&#9; 52 samples Frontmost App, User mode, Thread QoS User Interactive User Activity:&#9; 0 samples Idle, 55 samples Active Power Source:&#9;&#9;0 samples on Battery, 55 samples on AC &#9;55 start + 1 (libdyld.dylib) [0x7fff8bed55ad] &#9;&#9;55 main + 121 (MyApp) [0x108ee8d5f] &#9;&#9;&#9;55 NSApplicationMain + 1176 (AppKit) [0x7fff8ffed368] &#9;&#9;&#9;&#9;55 -[NSApplication run] + 682 (AppKit) [0x7fff90023d80] &#9;&#9;&#9;&#9;&#9;55 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454 (AppKit) [0x7fff9002f226] &#9;&#9;&#9;&#9;&#9;&#9;55 _DPSNextEvent + 1067 (AppKit) [0x7fff9002fdf6] &#9;&#9;&#9;&#9;&#9;&#9;&#9;55 _BlockUntilNextEventMatchingListInModeWithFilter + 71 (HIToolbox) [0x7fff866e35af] &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;55 ReceiveNextEventCommon + 184 (HIToolbox) [0x7fff866e3677] &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;55 RunCurrentEventLoopInMode + 235 (HIToolbox) [0x7fff866e3935] &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;55 CFRunLoopRunSpecific + 328 (CoreFoundation) [0x7fff973d5e48] &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;55 __CFRunLoopDoObservers + 391 (CoreFoundation) [0x7fff973f6f37] &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;55 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 (CoreFoundation) [0x7fff973f6fc7] &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;55 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 71 (QuartzCore) [0x7fff99fcf863] ...and on and on, much deeper How do I interpret these diagnostic files? Can someone link to some Apple documentation of them?
Posted Last updated
.
Post marked as solved
3 Replies
1.1k Views
Xcode 12 running on Catalina isn't offering me the option to build my Mac app for Apple Silicon, and the "Standard Architectures" option in the Architectures build setting just says Intel 64-Bit. Is Big Sur required to build for Apple Silicon? I don't see this anywhere on the docs page - https://developer.apple.com/documentation/xcode/building_a_universal_macos_binary.
Posted Last updated
.
Post not yet marked as solved
0 Replies
445 Views
I've got some C++ code with Doxygen documentation comments (the /**-style kind), and I'd love it if those showed up in Xcode's code completion. They do show up in Quick Help. And the triple-slash style documentation comments do show up in code completion. Anyone know how to make this work? Filed as Feedback FB7824467 with a sample project and screenshots.
Posted Last updated
.